﻿using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using TVersityDotNet.HelperTypes;
using System.Globalization;

namespace TVersityDotNet.Responses
{
    public class MediaSourceFetchListUpdateIdResponse : TVersityResponse
    {
        public int UpdateId { get; set; }

        public MediaSourceFetchListUpdateIdResponse(XDocument responseXmlDoc)
        {
            this.UpdateId = 0;
            this.ParseMessage(responseXmlDoc);            
        }

        public override void ParseMessage(XDocument responseXml)
        {
            if (responseXml != null)
            {
                base.ParseMessage(responseXml);
                if (this.ResponseSuccess)
                    this.UpdateId = int.Parse(responseXml.Element("response").Value, CultureInfo.InvariantCulture);
            }
            else
            {
                this.ResponseSuccess = false;
                this.ResponseMessage = "Provided responseXml was null";
            }
        }
    }
}
